/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package info.touret.winecellar.bottle.server.domain;


import info.touret.winecellar.dao.server.DataStoreObject;
import info.touret.winecellar.producer.server.domain.Producer;

import java.io.Serializable;

import javax.persistence.Basic;

import com.googlecode.objectify.annotation.Entity;


/**
 *
 * @author touret-a
 */
@Entity
public class Tag extends DataStoreObject<Producer> implements Serializable ,Comparable<Tag> {

    
    @Basic
    private String name;
    @Basic
    private Integer number;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getNumber() {
        return number;
    }

    public void setNumber(Integer number) {
        this.number = number;
    }

    public Tag(String name, Integer number) {
        this.name = name;
        this.number = number;
    }

    @Override
    public int compareTo(Tag o) {
        int compare = 1;

        if (o != null) {
            compare = getName().compareToIgnoreCase(o.getName());
        }

        return compare;
    }

    public Tag(String name) {
        this.name = name;
        this.number = 1;
    }

    private enum FONT_SIZE {

        smaller, small, medium, large, larger;
    }

    public String getFontSize() {
        String fontsize = new String("font-size:");
        if (getNumber() < 5) {
            fontsize = fontsize.concat(FONT_SIZE.smaller.toString());
        } else if (getNumber() < 10) {
            fontsize = fontsize.concat(FONT_SIZE.small.toString());
        } else if (getNumber() < 15) {
            fontsize = fontsize.concat(FONT_SIZE.medium.toString());
        } else if (getNumber() < 20) {
            fontsize = fontsize.concat(FONT_SIZE.large.toString());
        } else {
            fontsize = fontsize.concat(FONT_SIZE.larger.toString());
        }
        return fontsize;
    }

    public Tag() {
    }

    public void increaseNumber(){
        setNumber(getNumber()+1);
    }
    
}
